import 'package:flutter/material.dart';

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Widget Test',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        splashColor: Colors.transparent,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Widget Test'),
      ),
      body: ContactsWidget(["fauks", "jay", "mj"]),
    );
  }
}

// 联系人列表组件，用于widget测试
class ContactsWidget extends StatefulWidget {
  final List<String> _contacts;

  ContactsWidget(this._contacts);

  @override
  _ContactsWidgetState createState() => _ContactsWidgetState();
}

class _ContactsWidgetState extends State<ContactsWidget> {
  int _count = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('联系人列表'),
      ),
      body: ListView(
        children: widget._contacts.map((name) {
          return Column(
            children: [
              ListTile(
                leading: Icon(Icons.people),
                title: Text(name),
              ),
              ActionChip(
                  label: Text("$_count"),
                  onPressed: () {
                    setState(() {
                      _count++;
                    });
                  })
            ],
          );
        }).toList(),
      ),
    );
  }
}
